package com.itfreer.special.index;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itfreer.form.api.BaseRestService;
import com.itfreer.form.api.BaseService;
import com.itfreer.utils.ResponseEntity;

import io.swagger.annotations.Api;

/**
 * 定义指标Rest服务接口
 */
@RestController
@RequestMapping("/indexdata")
@Api("指标")
public class RestIndexDataService extends BaseRestService<IndexDataEntity> {

	@Autowired(required = false)
	private IndexDataService service;

	@Reference(lazy = true, check = false)
	private IndexDataService dubboService;

	@Override
	protected BaseService<IndexDataEntity> getService() {
		return getServiceEx();
	}
	
	private IndexDataService getServiceEx() {
		if (service == null) {
			return dubboService;
		} else {
			return service;
		}
	}

	@RequestMapping("/getIndexDataBy")
	public ResponseEntity<List<Map<String, Object>>> selectIndextBy(@RequestBody Map<String, Object> map) {
		return new ResponseEntity<List<Map<String, Object>>>(getServiceEx().getIndexDataBy(map));
	}

	@RequestMapping("/selectIndexName")
	public ResponseEntity<List<Map<String, Object>>> selectIndexName(@RequestBody Map<String, Object> map) {
		return new ResponseEntity<List<Map<String, Object>>>(getServiceEx().selectIndexName(map));
	}
}
